//
//  GPRegularExpression.m
//  MicroStock
//
//  Created by 劉帆 on 16/5/3.
//  Copyright © 2016年 GuangZhou Heng Rui Asset Management Co., LTD. All rights reserved.
//

#import "GPRegularExpression.h"

@implementation GPRegularExpression


+ (BOOL) regularExpressionWithMobileNumber:(NSString *)mobile {
    //手机号以13，14, 15，17,18开头，八个 \d 数字字符
    NSString *phoneRegex   = @"^((13[0-9])|(15[^4])|(18[0-9])|(17[0-8])|(14[579]))\\d{8}$";
    NSPredicate *phoneTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",phoneRegex];
    return [phoneTest evaluateWithObject:mobile];
}


+ (BOOL) regularExpressionWithIdentityCard:(NSString *)identityCard {
    BOOL flag;
    if (identityCard.length <= 0) {
        flag = NO;
        return flag;
    }
    NSString *regex2                   = @"^(\\d{14}|\\d{17})(\\d|[xX])$";
    NSPredicate *identityCardPredicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex2];
    return [identityCardPredicate evaluateWithObject:identityCard];
}


+ (BOOL) regularExpressionWithBankCardNumber:(NSString *)bankCardNumber {
    BOOL flag;
    if (bankCardNumber.length <= 0) {
        flag = NO;
        return flag;
    }
    NSString *regex2 = @"^(\\d{15,30})";
    NSPredicate *bankCardPredicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex2];
    return [bankCardPredicate evaluateWithObject:bankCardNumber];
}


@end
